#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MAXN = 100010;

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

int main() {
    int t;
    scanf("%d", &t);
    while (t--) {
        ll x;
        scanf("%lld", &x);
        ll l = 2, r = 63;
        bool found = false;
        while (l <= r && !found) {
            ll mid = (l + r) / 2;
            ll bl = 2, br = (ll)pow(x, 1.0 / mid) + 1;
            while (bl <= br && !found) {
                ll bmid = (bl + br) / 2;
                ll cur = 1, bk = mid - 1;
                while (bk--) {
                    cur *= bmid;
                    if (cur > x) {
                        break;
                    }
                }
                if (cur == x * (bmid - 1)) {
                    found = true;
                    break;
                } else if (cur > x * (bmid - 1)) {
                    br = bmid - 1;
                } else {
                    bl = bmid + 1;
                }
            }
            if (!found) {
                l = mid + 1;
            }
        }
        if (found) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
    return 0;
}
